<?php
/*
	通用控制器
*/
namespace Association\Controller;
use Think\Controller;
class CommonController extends Controller {
	public function _initialize(){
		if(!cookie('masterid')){
			//echo "<script>window.parent.location.reload()</script>";
			$this->error('未登录!页面跳转中...','/Association/Login/login',2);
			//redirect('/Admin/Login/login', 2, '未登录!页面跳转中...');
		}
		
		
		//附件上传清理session
		if(I('session.file')){
			//dump(I('session.file'));
			//上传附件
			$db3 = M('attachment');
			//$db3 -> create();
			foreach(I('session.file') as $val){
				unset($val['state']);
				//$val['uid'] = I('cookie.uid');
				//$val['aid'] = $aid;
				$db3 ->data($val) -> add();
			}
			session('file',null); // 删除name
			//上传附件
		}
	}
	
	function error404(){
		$this -> display('./admin-404');
	}
        
}